package com.gooluke.redismap.config;

import com.gooluke.redismap.properties.RedisMapProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(RedisMapProperties.class)
@ConditionalOnProperty(prefix = "redis-map", name = "enabled", havingValue = "true", matchIfMissing = true)
public class RedisMapAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public StringRedisMapManager stringRedisMapManager(RedisMapProperties redisMapProperties) {
        return new StringRedisMapManager(redisMapProperties);
    }
}